Skip to content

Conversation

javanna
Copy link
Member

@javanna javanna commented Oct 7, 2025

There's situations where the time range filter is provided as part of the retriever tree. In that case, we capture the time range filter from while parsing it, but we don't do the corresponding introspection of the retriever tree to extract which fields were the time range filters made against.

This commit introduces a very basic introspection of retrievers and tests around it, expanding on #135549.

There's situations where the time range filter is provided as part of the retriever tree.
In that case, we capture the time range filter from while parsing it, but we don't do
the corresponding introspection of the retriever tree to extract which fields were
the time range filters made against.

This commit introduces a very basic introspection of retrievers and tests around it.
@javanna javanna requested a review from andreidan October 7, 2025 09:55
@javanna javanna added >enhancement :Search Foundations/Search Catch all for Search Foundations v9.3.0 labels Oct 7, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Oct 7, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @javanna, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

}
}

private static void introspectRetriever(RetrieverBuilder retrieverBuilder, QueryMetadataBuilder queryMetadataBuilder, int level) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not particularly happy about having to make this change. I think that retrievers with a time range filter are a bit of an edge case that is not so important for our current metrics effort around search performance.

That said, this change is required to avoid weird discrepancies due to the very general way that we track the time range filter from, without extensive knowledge of where we get it from. We could disable tracking it in certain situations as an alternative, but retrievers get rewritten to ordinary queries hence at the shard level we don't have the info to be able to make the distinction.

@javanna javanna enabled auto-merge (squash) October 7, 2025 09:59
@javanna javanna disabled auto-merge October 7, 2025 10:04
@javanna javanna enabled auto-merge (squash) October 7, 2025 10:04
Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Luca

private static void assertTimeRangeAttributes(List<Measurement> measurements, String target, boolean isSystem) {
public void testTimeRangeFilterRetrieverOneResult() {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.retriever(new StandardRetrieverBuilder(new RangeQueryBuilder("@timestamp").from("2024-12-01")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice test, thank you !

@javanna javanna merged commit aae6742 into elastic:main Oct 7, 2025
34 checks passed
@javanna javanna deleted the enhancement/time_range_slicing_retrievers branch October 7, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants